package com.glsc.ngateway.platform.utils.file;

import lombok.Getter;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;

/**
 * excel枚举
 */
@Getter
public enum ExcelNameEnum {

    DIGITAL_KEY_LIST("digital_key_list.xlsx", "数字证书清单.xlsx", 1, 0, null);

    private final String fileName;
    private final String fileDesc;
    private final int beginRow;
    private final int beginCol;
    private final Class entityClass;

    ExcelNameEnum(String fileName, String fileDesc, int beginRow, int beginCol, Class entityClass) {
        this.fileName = fileName;
        this.fileDesc = fileDesc;
        this.beginRow = beginRow;
        this.beginCol = beginCol;
        this.entityClass = entityClass;
    }

    /**
     * 获取名称
     * @param fileName 文件名称
     * @return 获取excel模板
     */
    public static ExcelNameEnum getValueByName(String fileName) {
        return Arrays.stream(ExcelNameEnum.values())
            .filter(status -> StringUtils.equals(status.fileName, fileName))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("no ExcelNameEnum found for " + fileName));
    }
}
